﻿using com.ytocargo.Core.AcarsInfos;
using com.ytocargo.Core.AirCraftInfos;
using com.ytocargo.Core.AirPortCharts;
using com.ytocargo.Core.AirPortInfos;
using com.ytocargo.Core.BackgroundJobInfos;
using com.ytocargo.Core.Charts;
using com.ytocargo.Core.FlightCfps;
using com.ytocargo.Core.FlightInfo4Monitors;
using com.ytocargo.Core.FlightInfos;
using com.ytocargo.Core.FlightPlanMakeLogs;
using com.ytocargo.Core.FplRouteDetails;
using com.ytocargo.Core.GeneralDocs;
using com.ytocargo.Core.SystemSettings;
using com.ytocargo.Core.Users;
using System.Data.Entity;
using Yto.EF;

namespace com.ytocargo.EntityFramework.DbCtx
{
    public class YtocargoDbContext : YtoDbContext<YtoUser>
    {
        public virtual IDbSet<BackgroundJobInfo> BackgroundJobInfos { get; set; }
        public virtual IDbSet<SystemSetting> SystemSettings { get; set; }
        public virtual IDbSet<Chart> Charts { get; set; }
        public virtual IDbSet<GeneralDoc> GeneralDocs { get; set; }

        public virtual IDbSet<FlightInfo4Monitor> FlightInfo4Monitors { get; set; }

        //FOC foc1
        public virtual IDbSet<AirPortChart> AirPortCharts { get; set; }
        public virtual IDbSet<AirPortInfo> AirPortInfos { get; set; }

        //foc2
        public virtual IDbSet<FlightInfo> FlightInfos { get; set; }
        public virtual IDbSet<AcarsInfo> AcarsInfos { get; set; }
        public virtual IDbSet<FlightPlanMakeLog> FlightPlanMakeLogs { get; set; }
        public virtual IDbSet<FplRouteDetail> FplRouteDetails { get; set; }
        public virtual IDbSet<FlightCfp> FlightCfps { get; set; }

        //foc3
        public virtual IDbSet<AirCraftInfo> AirCraftInfos { get; set; }

        public YtocargoDbContext() : this("Oracle")
        {
            Database.SetInitializer<YtocargoDbContext>(null);
        }

        public YtocargoDbContext(string nameOrConnectionString) : base(nameOrConnectionString)
        {

        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.HasDefaultSchema("YGFOC");
            modelBuilder.Types().Configure(x => x.ToTable(EFStartup.SetTableName(x.ClrType.Name)));
            modelBuilder.Properties().Configure(c => c.HasColumnName(c.ClrPropertyInfo.Name.ToUpper()));
        }
    }
}
